/*
 * Powered By [rapid-framework]
 * Web Site: http://www.rapid-framework.org.cn
 * Google Code: http://code.google.com/p/rapid-framework/
 * Since 2008 - 2011
 */

package com.nail.zhaogr.model;

import javax.persistence.*;

import org.hibernate.annotations.GenericGenerator;

import javax.validation.constraints.*;
import org.hibernate.validator.constraints.*;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

import java.util.*;

import javacommon.base.*;
import javacommon.util.*;

import cn.org.rapid_framework.util.*;
import cn.org.rapid_framework.web.util.*;
import cn.org.rapid_framework.page.*;
import cn.org.rapid_framework.page.impl.*;

import com.nail.zhaogr.model.*;
import com.nail.zhaogr.dao.*;
import com.nail.zhaogr.service.*;
import com.nail.zhaogr.vo.query.*;

/**
 * @author badqiu email:badqiu(a)gmail.com
 * @version 1.0
 * @since 1.0
 */


@Entity
@Table(name = "city")
public class City extends BaseEntity implements java.io.Serializable{
	private static final long serialVersionUID = 5454155825314635342L;
	
	//alias
	public static final String TABLE_ALIAS = "City";
	public static final String ALIAS_CITY_ID = "cityId";
	public static final String ALIAS_PARENT_CITY_ID = "parentCityId";
	public static final String ALIAS_NAME = "name";
	public static final String ALIAS_CODE = "code";
	public static final String ALIAS_LEVEL = "level";
	
	//date formats
	

	//可以直接使用: @Length(max=50,message="用户名长度不能大于50")显示错误消息
	//columns START
    /**
     * cityId       db_column: cityId 
     */ 	
	
	private java.lang.Long cityId;
    /**
     * parentCityId       db_column: parentCityId 
     */ 	
	
	private java.lang.Long parentCityId;
    /**
     * name       db_column: name 
     */ 	
	@NotBlank @Length(max=50)
	private java.lang.String name;
    /**
     * code       db_column: code 
     */ 	
	@Length(max=16)
	private java.lang.String code;
    /**
     * level       db_column: level 
     */ 	
	
	private java.lang.Integer level;
	//columns END


	public City(){
	}

	public City(
		java.lang.Long cityId
	){
		this.cityId = cityId;
	}

	

	public void setCityId(java.lang.Long value) {
		this.cityId = value;
	}
	
	@Id @GeneratedValue(generator="custom-id")
	@GenericGenerator(name="custom-id", strategy = "increment")
	@Column(name = "cityId", unique = true, nullable = false, insertable = true, updatable = true, length = 19)
	public java.lang.Long getCityId() {
		return this.cityId;
	}
	
	@Column(name = "parentCityId", unique = false, nullable = true, insertable = true, updatable = true, length = 19)
	public java.lang.Long getParentCityId() {
		return this.parentCityId;
	}
	
	public void setParentCityId(java.lang.Long value) {
		this.parentCityId = value;
	}
	
	@Column(name = "name", unique = false, nullable = false, insertable = true, updatable = true, length = 50)
	public java.lang.String getName() {
		return this.name;
	}
	
	public void setName(java.lang.String value) {
		this.name = value;
	}
	
	@Column(name = "code", unique = false, nullable = true, insertable = true, updatable = true, length = 16)
	public java.lang.String getCode() {
		return this.code;
	}
	
	public void setCode(java.lang.String value) {
		this.code = value;
	}
	
	@Column(name = "level", unique = false, nullable = true, insertable = true, updatable = true, length = 10)
	public java.lang.Integer getLevel() {
		return this.level;
	}
	
	public void setLevel(java.lang.Integer value) {
		this.level = value;
	}
	
	
	private Set publishInfos = new HashSet(0);
	public void setPublishInfos(Set<PublishInfo> publishInfo){
		this.publishInfos = publishInfo;
	}
	
	@OneToMany(cascade = { CascadeType.MERGE }, fetch = FetchType.LAZY, mappedBy = "city")
	public Set<PublishInfo> getPublishInfos() {
		return publishInfos;
	}
	
	private Set psnServiceAreas = new HashSet(0);
	public void setPsnServiceAreas(Set<PsnServiceArea> psnServiceArea){
		this.psnServiceAreas = psnServiceArea;
	}
	
	@OneToMany(cascade = { CascadeType.MERGE }, fetch = FetchType.LAZY, mappedBy = "city")
	public Set<PsnServiceArea> getPsnServiceAreas() {
		return psnServiceAreas;
	}
	
	private Set memberss = new HashSet(0);
	public void setMemberss(Set<Members> members){
		this.memberss = members;
	}
	
	@OneToMany(cascade = { CascadeType.MERGE }, fetch = FetchType.LAZY, mappedBy = "city")
	public Set<Members> getMemberss() {
		return memberss;
	}

	public String toString() {
		return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
			.append("CityId",getCityId())
			.append("ParentCityId",getParentCityId())
			.append("Name",getName())
			.append("Code",getCode())
			.append("Level",getLevel())
			.toString();
	}
	
	public int hashCode() {
		return new HashCodeBuilder()
			.append(getCityId())
			.toHashCode();
	}
	
	public boolean equals(Object obj) {
		if(obj instanceof City == false) return false;
		if(this == obj) return true;
		City other = (City)obj;
		return new EqualsBuilder()
			.append(getCityId(),other.getCityId())
			.isEquals();
	}
}

